import 'package:flutter/material.dart';
import 'package:flutter_structure/app/localization/localization_controller.dart';
import 'package:flutter_structure/app/theme/app_colors.dart';
import 'package:flutter_structure/common/config/config_path.dart';
import 'package:flutter_structure/common/widgets/ripple_button.dart';
import 'package:flutter_structure/common/widgets/slide_animation.dart';

class OpenPro {
  static SlideAnimation? _animationInstance;
  static void show({
    required AppColors theme
  }){
    _animationInstance = SlideAnimation(
      content: _content(theme),
      position: 'center',
      dismissOnBackgroundTap: false,
      beginOffset: const Offset(0, 1.0),
    );
    _animationInstance?.show();
  }


  static Widget _content(
    AppColors theme
  ){
    final key = LanguageController.to.locale.value == const Locale('zh', 'CN') ? 'cn' : 'en';
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 4 , vertical: 4),
      decoration: BoxDecoration(
        color: theme.subjectPure,
        borderRadius: BorderRadius.circular(8)
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          RippleButton(
            borderRadius: BorderRadius.circular(12),
            padding: const EdgeInsets.all(2),
            backgroundColor: theme.subjectMix1!,
            splashColor:theme.subjectMix3!.withOpacity(0.4) ,
            highlightColor:theme.subjectMix3!.withOpacity(0.4) ,
            onTap: (){
              _animationInstance?.close();
              _animationInstance = null;
            },
            child:const Icon(Icons.close , size: 14,)
          ),
          Image.asset(
            '${AppConfig.assetsMedia}subscribe-example-$key.png',
            width: 200,
            height: 150,
            fit: BoxFit.contain,
          )
        ],
      ),
    );
  }
}